import { customError, post, ReturnType } from '..'
import { TaskResponse } from '../interface'
import { URL_TASK, URL_TASK_DONE, URL_TASK_PRIZE } from '../base/url'


export const tasks = async (): Promise<ReturnType<TaskResponse[] | undefined>> => {
    try {
        const result = await post<TaskResponse[]>(URL_TASK)
        return result
    } catch (error: any) {
        return customError(error)
    }
}

export const taskPrize = async (params: { taskId: string }): Promise<ReturnType<undefined>> => {
    try {
        const result = await post(URL_TASK_PRIZE, params)
        return result
    } catch (error: any) {
        return customError(error)
    }
}

export const taskDone = async (params: { taskId: string }): Promise<ReturnType<undefined>> => {
    try {
        const result = await post(URL_TASK_DONE, params)
        return result
    } catch (error: any) {
        return customError(error)
    }
}

